package com.chiry.shop.user.service.impl;

import com.chiry.common.vo.Result;
import com.chiry.common.bo.user.UserBO;
import com.chiry.shop.user.mapper.UserMapper;
import com.chiry.shop.user.pojo.User;
import com.chiry.shop.user.service.UserService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author fyx
 * @version 1.0
 * @date 2021/12/9 19:03
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    UserMapper userMapper;

    @Override
    public Result<UserBO> findOne(Long id) {
        User user = userMapper.selectById(id);
        if (user == null) {
            return Result.fail(10001, "用户不存在");
        }
        UserBO userBO = new UserBO();
        BeanUtils.copyProperties(user, userBO);
        return Result.success(userBO);
    }
}
